<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/template/DefaultTemplate.xhtml">
        <ui:define name="content">
            <h:panelGroup id="messagePanel" layout="block">
                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
            </h:panelGroup>
            <h:form id ="form">
                <p:messages />
                <p:panel header="Information for this invoice: " style="text-align: left">
                    <h:panelGrid columns="2" style="width: 100%;"> 
                        
                      
                         <p:fieldset legend="Posted By:"  style="width:100">
                     
                                <br />
                                <h:outputText value="Merlion Food Ltd "/>
                                <br />      
                                <br />   
                                <h:outputText value ="21A Sierra Road "/> 
                                <br />
                                <h:outputText value ="Singapore 719283"/>
                                <br />




                                <br />
                                <h:outputText value="Bank: OCBC | Account: Merlion Food Ltd."/>
                                <br />
                                <h:outputText value=" Account No: 2349-2382-32"/>
                                <br />
                                <br />
                                <h:outputText value="Email: info@merlionfood.com"/>
                       
                         </p:fieldset>
                        <p:fieldset legend="Post To:"  style="width:100">

                         

                                <br/>
                                <h:outputText value="#{vendorInvoiceEntityController.selectedInvoice.rawMaterialPurchaseOrder.rmq.vendor.companyName}" />
                                <br />
                                <br />
                                <h:outputText value="#{vendorInvoiceEntityController.addresse.streetAddress}" />
                                <br/>

                                <h:outputText value="#{vendorInvoiceEntityController.addresse.city}" />                
                                <br/>
                                <h:outputText value="#{vendorInvoiceEntityController.addresse.stateOrProvice}"  />
                                <br/>

                                <h:outputText value="#{vendorInvoiceEntityController.addresse.country} &nbsp; #{vendorInvoiceEntityController.addresse.zipCode}"  />

                                <br />
                                <br />
                                <h:outputText value="Bank account:" />
                                <br/>
                                <h:outputText value="#{vendorInvoiceEntityController.selectedInvoice.rawMaterialPurchaseOrder.rmq.vendor.bankAccount}" />
                                <br />
                        </p:fieldset>
                     
                    </h:panelGrid>
                    <p:separator style="width:500px;height:3px" />

                    <br/>
                    <br/>
                    <p:panel header="Information for this invoice: " >
                        <h:outputText value="Product purchased: &nbsp;"/>

                        <h:outputText value="#{vendorInvoiceEntityController.selectedInvoice.rawMaterialPurchaseOrder.rmq.rawMaterial.productName}"/>
                        <br/>
                        <br/>
                        <h:outputText value="Invoice Id: &nbsp;"/>

                        <h:outputText value="#{vendorInvoiceEntityController.selectedInvoice.externalId}"/>
                        <br/>
                        <br/>
                        <h:outputText value="Total nominal Cost:($S) &nbsp;"/>

                        <h:outputText value="#{vendorInvoiceEntityController.selectedInvoice.cost}"/>
                        <br/>
                        <br/>
                        <h:outputText value="Tax amount:($S)  &nbsp;"/>

                        <h:outputText value="#{vendorInvoiceEntityController.selectedInvoice.taxAmount}"/>
                        <br/>
                        <br/>
                        <h:outputText value="Total amount due($S): &nbsp;"/>

                        <h:outputText value="#{vendorInvoiceEntityController.selectedInvoice.amount}"/>
                        <br/>
                        <br/>

                        <p:separator/>
                        <br/>

                  
                        <h:outputText value="Date Received: &nbsp;"/>
                        <h:outputText value="#{vendorInvoiceEntityController.selectedInvoice.dateReceived}" > 
                            <f:convertDateTime pattern="dd/MM/yyyy" />
                        </h:outputText>

                        <br/>

                        <h:outputText value="Date due: &nbsp;"/>
                        <h:outputText value="#{vendorInvoiceEntityController.selectedInvoice.dueDate}" > 
                            <f:convertDateTime pattern="dd/MM/yyyy" />
                        </h:outputText>

                        <br/>

                    </p:panel>

                </p:panel>
                <p:separator/>

                <p:panel header="Applicable for the Shipment:">
                    <p:outputPanel id="books">  
                        <p:dataTable value="#{vendorInvoiceEntityController.scheduleShip}" var="entry" >
                            <p:column>
                                <f:facet name="header" >
                                    <h:outputText value="Shipment date:"/>
                                </f:facet>
                                <p:dataTable value="#{entry}" var="type" >
                                    <p:column>

                                        <h:outputText value="#{type.key}">
                                            <f:convertDateTime pattern="dd/MM/yyyy" />
                                        </h:outputText>

                                    </p:column>
                                </p:dataTable>
                            </p:column>
                            <p:column>
                                <f:facet name="header" >
                                    <h:outputText value="Amount:"/>
                                </f:facet>
                                <p:dataTable value="#{entry}" var="type" >
                                    <p:column>

                                        <h:outputText value="#{type.value}"/>

                                    </p:column>
                                </p:dataTable>
                            </p:column>



                        </p:dataTable>
                    </p:outputPanel>  
                </p:panel>


                <p:separator/>




                <p:commandButton ajax="false" value="Post payment" onclick="confirmation.show()" type="button" update ="growl" rendered="#{vendorInvoiceEntityController.pending}"/>
         
   <p:commandButton action="#{vendorInvoiceEntityController.enddd}" ajax="false" value="Back" />  
   <br/>
   <br/>
                <h:commandLink  title="Download" actionListener="#{vendorInvoiceEntityController.exportToPDF}" rendered="#{vendorInvoiceEntityController.pending}">  

                    <p:graphicImage value="/images/download.gif" />  

                    <p:fileDownload value="#{invoiceDownload.file}"/>  
                </h:commandLink>  


                <p:confirmDialog message="You are about to make a payment to this invoice.Are you ready?"  
                                 showEffect="bounce" hideEffect="explode"  
                                 header="Payment initiating" severity="alert" widgetVar="confirmation">  

                    <p:commandButton value="Yes Sure" update="growl" oncomplete="confirmation.hide()"  
                                     actionListener="#{vendorInvoiceEntityController.preparePost}" />  
                    <p:commandButton value="Not Yet" onclick="confirmation.hide()" type="button" />
                </p:confirmDialog> 

            </h:form>
        </ui:define>
    </ui:composition>

</html>